﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace WindowsFormsApplication1
{
    public partial class frmMain : Form
    {
        public frmMain()
        {
            InitializeComponent();
        }

        private void frmMain_Load(object sender, EventArgs e)
        {

        }


        private void chkALL_CheckedChanged(object sender, EventArgs e)
        {
            if (chkALL.Checked == true)
            {
                foreach (Control control in grpClasses.Controls)
                {
                    if (control.GetType() == typeof(CheckBox))
                    {
                        ((CheckBox)control).Checked = true;
                    }
                }
                foreach (Control control in grpQuick.Controls)
                {
                    if (control.GetType() == typeof(CheckBox) && control.Name != "chkALL")
                    {
                        ((CheckBox)control).Checked = true;
                    }
                }
            }
            else
            {
                foreach (Control control in grpClasses.Controls)
                {
                    if (control.GetType() == typeof(CheckBox))
                    {
                        ((CheckBox)control).Checked = false;
                    }
                }
                foreach (Control control in grpQuick.Controls)
                {
                    if (control.GetType() == typeof(CheckBox) && control.Name != "chkALL")
                    {
                        ((CheckBox)control).Checked = false;
                    }
                }
            }
        }

        private void chkINT_CheckedChanged(object sender, EventArgs e)
        {
            if (chkINT.Checked == true)
            {
                chkENC.Checked = true;
                chkMAG.Checked = true;
                chkNEC.Checked = true;
                chkWIZ.Checked = true;
            }
            else
            {
                chkENC.Checked = false;
                chkMAG.Checked = false;
                chkNEC.Checked = false;
                chkWIZ.Checked = false;
            }
        }

        private void chkWIS_CheckedChanged(object sender, EventArgs e)
        {
            if (chkWIS.Checked == true)
            {
                chkCLE.Checked = true;
                chkDRU.Checked = true;
                chkSHM.Checked = true;
            }
            else
            {
                chkCLE.Checked = false;
                chkDRU.Checked = false;
                chkSHM.Checked = false;
            }
        }

        private void chkMELEE_CheckedChanged(object sender, EventArgs e)
        {
            if (chkMELEE.Checked == true)
            {
                chkBER.Checked = true;
                chkBRD.Checked = true;
                chkBST.Checked = true;
                chkMNK.Checked = true;
                chkRNG.Checked = true;
                chkROG.Checked = true;
            }
            else
            {
                chkBER.Checked = false;
                chkBRD.Checked = false;
                chkBST.Checked = false;
                chkMNK.Checked = false;
                chkRNG.Checked = false;
                chkROG.Checked = false;
            }
        }

        private void chkTANKS_CheckedChanged(object sender, EventArgs e)
        {
            if (chkTANKS.Checked == true)
            {
                chkPAL.Checked = true;
                chkSHD.Checked = true;
                chkWAR.Checked = true;
            }
            else
            {
                chkPAL.Checked = false;
                chkSHD.Checked = false;
                chkWAR.Checked = false;
            }
        }

        private void chkALLSlots_CheckedChanged(object sender, EventArgs e)
        {
            if (chkALLSlots.Checked == true)
            {
                foreach (Control control in grpSlots.Controls)
                {
                    if (control.GetType() == typeof(CheckBox))
                    {
                        ((CheckBox)control).Checked = true;
                    }
                }
                foreach (Control control in grpQuickSlots.Controls)
                {
                    if (control.GetType() == typeof(CheckBox) && control.Name != "chkALL")
                    {
                        ((CheckBox)control).Checked = true;
                    }
                }
            }
            else
            {
                foreach (Control control in grpSlots.Controls)
                {
                    if (control.GetType() == typeof(CheckBox))
                    {
                        ((CheckBox)control).Checked = false;
                    }
                }
                foreach (Control control in grpQuickSlots.Controls)
                {
                    if (control.GetType() == typeof(CheckBox) && control.Name != "chkALL")
                    {
                        ((CheckBox)control).Checked = false;
                    }
                }
            }
        }

        private void chkALLArmor_CheckedChanged(object sender, EventArgs e)
        {
            if (chkALLArmor.Checked == true)
            {
                chkEARS.Checked = true;
                chkHEAD.Checked = true;
                chkFACE.Checked = true;
                chkCHEST.Checked = true;
                chkARMS.Checked = true;
                chkWAIST.Checked = true;
                chkWRISTS.Checked = true;
                chkLEGS.Checked = true;
                chkNECK.Checked = true;
                chkBACK.Checked = true;
                chkSHOULDERS.Checked = true;
                chkFEET.Checked = true;
                chkHANDS.Checked = true;
                chkCHARM.Checked = true;
                chkFINGERS.Checked = true;
            }
            else
            {
                chkEARS.Checked = false;
                chkHEAD.Checked = false;
                chkFACE.Checked = false;
                chkCHEST.Checked = false;
                chkARMS.Checked = false;
                chkWAIST.Checked = false;
                chkWRISTS.Checked = false;
                chkLEGS.Checked = false;
                chkNECK.Checked = false;
                chkBACK.Checked = false;
                chkSHOULDERS.Checked = false;
                chkFEET.Checked = false;
                chkHANDS.Checked = false;
                chkCHARM.Checked = false;
                chkFINGERS.Checked = false;
            }
        }

        private void chkALLWeapons_CheckedChanged(object sender, EventArgs e)
        {
            if (chkALLWeapons.Checked == true)
            {
                chkPRIMARY.Checked = true;
                chkSECONDARY.Checked = true;
                chkRANGED.Checked = true;
            }
            else
            {
                chkPRIMARY.Checked = false;
                chkSECONDARY.Checked = false;
                chkRANGED.Checked = false;
            }
        }

        private void btnGenerate_Click(object sender, EventArgs e)
        {
            // Set item name
            lblName.Text = txtName.Text;

            // Set Classes
            lblClasses.Text = "";
            foreach (Control control in grpClasses.Controls)
            {
                if (control.GetType() == typeof(CheckBox))
                {
                    if (((CheckBox)control).Checked == true)
                    {
                        if (lblClasses.Text == "")
                        {
                            lblClasses.Text = lblClasses.Text + ((CheckBox)control).Text;
                        }
                        else
                        {
                            lblClasses.Text = lblClasses.Text + ", " + ((CheckBox)control).Text;
                        }
                    }
                }
            }

            // Set Tier
            lblTier.Text = Convert.ToString(cboTier.SelectedItem);
            // Set Type
            lblType.Text = Convert.ToString(cboType.SelectedItem);

            // Set Equipment Slots
            lblSlots.Text = "";
            lblSlots.Tag = "Other";
            foreach (Control control in grpSlots.Controls)
            {
                if (control.GetType() == typeof(CheckBox))
                {
                    if (((CheckBox)control).Checked == true)
                    {
                        if (((CheckBox)control).Text == "Legs")
                        {
                            lblSlots.Tag = "Legs";
                        }
                        else if (((CheckBox)control).Text == "Chest")
                        {
                            lblSlots.Tag = "Chest";
                        }

                        if (lblSlots.Text == "")
                        {
                            lblSlots.Text = lblSlots.Text + ((CheckBox)control).Text;
                        }
                        else
                        {
                            lblSlots.Text = lblSlots.Text + ", " + ((CheckBox)control).Text;
                        }
                    }
                }
            }

            // Populating Hit Points, Mana, Endurance
            CalcHPMANAEND(cboTier.SelectedIndex, Convert.ToString(lblSlots.Tag), chkBOSS.Checked, chkDONOR.Checked);

            // Populate Stats - STR, STA, DEX, INT, etc.
            CalcSTATS(lblClasses.Text, cboTier.SelectedIndex, chkBOSS.Checked, chkDONOR.Checked);

            // Populate Heroic Stats - STR, STA, DEX, INT, etc.
            CalcHSTATS(cboTier.SelectedIndex, chkBOSS.Checked, chkDONOR.Checked, Convert.ToString(lblSlots.Tag));

            // Calculate AC value of items.
            CalcAC(cboTier.SelectedIndex, Convert.ToString(cboTypeMaterial.SelectedItem), chkBOSS.Checked, chkDONOR.Checked, Convert.ToString(lblSlots.Tag));

            // Calculate Damage value of items.
            CalcDAMAGE(cboTier.SelectedIndex, Convert.ToString(cboTypeMaterial.SelectedItem), chkBOSS.Checked, chkDONOR.Checked, Convert.ToString(lblSlots.Tag));
        }

        private void cboType_SelectedIndexChanged(object sender, EventArgs e)
        {
            cboTypeMaterial.Items.Clear();
            cboTypeMaterial.SelectedText = "";

            if (Convert.ToString(cboType.SelectedItem) == "Weapon")
            {
                cboTypeMaterial.Items.Add("Archery");
                cboTypeMaterial.Items.Add("1h Blunt");
                cboTypeMaterial.Items.Add("2h Blunt");
                cboTypeMaterial.Items.Add("1h Piercing");
                cboTypeMaterial.Items.Add("2h Piercing");
                cboTypeMaterial.Items.Add("1h Slashing");
                cboTypeMaterial.Items.Add("2h Slashing");
                cboTypeMaterial.Items.Add("Martial");
            }
            if (Convert.ToString(cboType.SelectedItem) == "Armor")
            {
                cboTypeMaterial.Items.Add("Silk");
                cboTypeMaterial.Items.Add("Leather");
                cboTypeMaterial.Items.Add("Chain");
                cboTypeMaterial.Items.Add("Plate");
                cboTypeMaterial.Items.Add("Shield");
                cboTypeMaterial.Items.Add("Accessory");
            }
        }

        private void CalcHPMANAEND(int intTier, string strTopSlot, bool boolBoss, bool boolDonor)
        {
            int[] T1Array = { 485, 450, 360 };      // Donor gear levels - CHEST, LEGS, OTHER
            int intDungeon = 90;                    // % difference between End Boss and Dungeon loot (HUNDREDS - EX. 90 / 100)
            int intTierToTier = 1750;               // % difference between Tier and Tier gear. (THOUSANDS - EX. 1750 / 10000)
            int intDonorToTier = 2500;              // % difference between Donor and Tier gear. (THOUSANDS - EX. 2500 / 10000)

            if (strTopSlot == "Chest")
            {
                if (boolBoss)
                {
                    int toCalculate = (((Convert.ToInt32(T1Array.GetValue(0)) * intTierToTier / 10000) * (intTier - 1)) + Convert.ToInt32(T1Array.GetValue(0)));
                    txtHP.Text = Convert.ToString(Math.Round(Convert.ToDouble(toCalculate / 10.0)) * 10);
                    txtMANA.Text = Convert.ToString(Math.Round(Convert.ToDouble(toCalculate / 10.0)) * 10);
                    txtEND.Text = Convert.ToString(Math.Round(Convert.ToDouble(toCalculate / 10.0)) * 10);
                }
                else
                {
                    int toCalculate = (((Convert.ToInt32(T1Array.GetValue(0)) * intTierToTier / 10000) * (intTier - 1)) + Convert.ToInt32(T1Array.GetValue(0)) * intDungeon / 100);
                    txtHP.Text = Convert.ToString(Math.Round(Convert.ToDouble(toCalculate / 10.0)) * 10);
                    txtMANA.Text = Convert.ToString(Math.Round(Convert.ToDouble(toCalculate / 10.0)) * 10);
                    txtEND.Text = Convert.ToString(Math.Round(Convert.ToDouble(toCalculate / 10.0)) * 10);
                }

                if (boolDonor)
                {
                    int toCalculate = (((Convert.ToInt32(T1Array.GetValue(0)) * intDonorToTier / 10000) * (intTier - 1)) + Convert.ToInt32(T1Array.GetValue(0)));
                    txtHP.Text = Convert.ToString(Math.Round(Convert.ToDouble(toCalculate / 10.0)) * 10);
                    txtMANA.Text = Convert.ToString(Math.Round(Convert.ToDouble(toCalculate / 10.0)) * 10);
                    txtEND.Text = Convert.ToString(Math.Round(Convert.ToDouble(toCalculate / 10.0)) * 10);
                }
            }
            else if (strTopSlot == "Legs")
            {
                if (boolBoss)
                {
                    int toCalculate = (((Convert.ToInt32(T1Array.GetValue(1)) * intTierToTier / 10000) * (intTier - 1)) + Convert.ToInt32(T1Array.GetValue(1)));
                    txtHP.Text = Convert.ToString(Math.Round(Convert.ToDouble(toCalculate / 10.0)) * 10);
                    txtMANA.Text = Convert.ToString(Math.Round(Convert.ToDouble(toCalculate / 10.0)) * 10);
                    txtEND.Text = Convert.ToString(Math.Round(Convert.ToDouble(toCalculate / 10.0)) * 10);
                }
                else
                {
                    int toCalculate = (((Convert.ToInt32(T1Array.GetValue(1)) * intTierToTier / 10000) * (intTier - 1)) + Convert.ToInt32(T1Array.GetValue(1)) * intDungeon / 100);
                    txtHP.Text = Convert.ToString(Math.Round(Convert.ToDouble(toCalculate / 10.0)) * 10);
                    txtMANA.Text = Convert.ToString(Math.Round(Convert.ToDouble(toCalculate / 10.0)) * 10);
                    txtEND.Text = Convert.ToString(Math.Round(Convert.ToDouble(toCalculate / 10.0)) * 10);
                }

                if (boolDonor)
                {
                    int toCalculate = (((Convert.ToInt32(T1Array.GetValue(1)) * intDonorToTier / 10000) * (intTier - 1)) + Convert.ToInt32(T1Array.GetValue(1)));
                    txtHP.Text = Convert.ToString(Math.Round(Convert.ToDouble(toCalculate / 10.0)) * 10);
                    txtMANA.Text = Convert.ToString(Math.Round(Convert.ToDouble(toCalculate / 10.0)) * 10);
                    txtEND.Text = Convert.ToString(Math.Round(Convert.ToDouble(toCalculate / 10.0)) * 10);
                }
            }
            else
            {
                if (boolBoss)
                {
                    int toCalculate = (((Convert.ToInt32(T1Array.GetValue(2)) * intTierToTier / 10000) * (intTier - 1)) + Convert.ToInt32(T1Array.GetValue(2)));
                    txtHP.Text = Convert.ToString(Math.Round(Convert.ToDouble(toCalculate / 10.0)) * 10);
                    txtMANA.Text = Convert.ToString(Math.Round(Convert.ToDouble(toCalculate / 10.0)) * 10);
                    txtEND.Text = Convert.ToString(Math.Round(Convert.ToDouble(toCalculate / 10.0)) * 10);
                }
                else
                {
                    int toCalculate = (((Convert.ToInt32(T1Array.GetValue(2)) * intTierToTier / 10000) * (intTier - 1)) + Convert.ToInt32(T1Array.GetValue(2)) * intDungeon / 100);
                    txtHP.Text = Convert.ToString(Math.Round(Convert.ToDouble(toCalculate / 10.0)) * 10);
                    txtMANA.Text = Convert.ToString(Math.Round(Convert.ToDouble(toCalculate / 10.0)) * 10);
                    txtEND.Text = Convert.ToString(Math.Round(Convert.ToDouble(toCalculate / 10.0)) * 10);
                }

                if (boolDonor)
                {
                    int toCalculate = (((Convert.ToInt32(T1Array.GetValue(2)) * intDonorToTier / 10000) * (intTier - 1)) + Convert.ToInt32(T1Array.GetValue(2)));
                    txtHP.Text = Convert.ToString(Math.Round(Convert.ToDouble(toCalculate / 10.0)) * 10);
                    txtMANA.Text = Convert.ToString(Math.Round(Convert.ToDouble(toCalculate / 10.0)) * 10);
                    txtEND.Text = Convert.ToString(Math.Round(Convert.ToDouble(toCalculate / 10.0)) * 10);
                }
            }
        }

        private void CalcSTATS(string strClasses, int intTier, bool boolBoss, bool boolDonor)
        {
            // STAT arrays by class - STR,STA,AGI,DEX,WIS,INT,CHA
            // Each class = 15 total
            // Each stat weighting = ~14% of total sum
            // WARNING: MESSING WITH THIS WILL HAVE BIG CONSEQUENCES...
            int[] BER = {10,8,6,8,6,6,6};
            int[] BRD = {8,6,8,6,6,6,10};
            int[] BST = {8,6,8,8,8,6,6};
            int[] CLE = {8,8,6,6,10,6,6};
            int[] DRU = {6,6,8,6,10,6,8};
            int[] ENC = {6,8,6,6,6,8,10};
            int[] MAG = {6,6,6,8,8,10,6};
            int[] MNK = {8,8,10,6,6,6,6};
            int[] NEC = {6,10,6,6,6,8,8};
            int[] PAL = {8,10,6,6,8,6,6};
            int[] RNG = {6,8,8,10,6,6,6};
            int[] ROG = {6,8,8,10,6,6,6};
            int[] SHD = {8,10,6,6,6,8,6};
            int[] SHM = {8,6,6,6,10,8,6};
            int[] WAR = {8,10,8,6,6,6,6};
            int[] WIZ = {8,6,8,6,6,10,6};

            int[] valueSTATS = { 0, 0, 0, 0, 0, 0, 0 };
            int totalSTATS;

            int baseStats = 85;                     // Base number of stats on a Tier 1 item.
            int intDungeon = 90;                    // % difference between End Boss and Dungeon stats (HUNDREDS - EX. 90 / 100)
            int intTierToTier = 1700;               // % difference between Tier and Tier gear. (THOUSANDS - EX. 1750 / 10000)
            int intDonorToTier = 2700;              // % difference between Donor and Tier gear. (THOUSANDS - EX. 2500 / 10000)

            List<string> arrayClasses = strClasses.Split(',').ToList(); // Convert list of classes into array

            if (arrayClasses.Contains("BER") || arrayClasses.Contains(" BER"))
            {
                valueSTATS.SetValue(Convert.ToInt32(valueSTATS.GetValue(0)) + Convert.ToInt32(BER.GetValue(0)), 0);
                valueSTATS.SetValue(Convert.ToInt32(valueSTATS.GetValue(1)) + Convert.ToInt32(BER.GetValue(1)), 1);
                valueSTATS.SetValue(Convert.ToInt32(valueSTATS.GetValue(2)) + Convert.ToInt32(BER.GetValue(2)), 2);
                valueSTATS.SetValue(Convert.ToInt32(valueSTATS.GetValue(3)) + Convert.ToInt32(BER.GetValue(3)), 3);
                valueSTATS.SetValue(Convert.ToInt32(valueSTATS.GetValue(4)) + Convert.ToInt32(BER.GetValue(4)), 4);
                valueSTATS.SetValue(Convert.ToInt32(valueSTATS.GetValue(5)) + Convert.ToInt32(BER.GetValue(5)), 5);
                valueSTATS.SetValue(Convert.ToInt32(valueSTATS.GetValue(6)) + Convert.ToInt32(BER.GetValue(6)), 6);
            }
            if (arrayClasses.Contains("BRD") || arrayClasses.Contains(" BRD"))
            {
                valueSTATS.SetValue(Convert.ToInt32(valueSTATS.GetValue(0)) + Convert.ToInt32(BRD.GetValue(0)), 0);
                valueSTATS.SetValue(Convert.ToInt32(valueSTATS.GetValue(1)) + Convert.ToInt32(BRD.GetValue(1)), 1);
                valueSTATS.SetValue(Convert.ToInt32(valueSTATS.GetValue(2)) + Convert.ToInt32(BRD.GetValue(2)), 2);
                valueSTATS.SetValue(Convert.ToInt32(valueSTATS.GetValue(3)) + Convert.ToInt32(BRD.GetValue(3)), 3);
                valueSTATS.SetValue(Convert.ToInt32(valueSTATS.GetValue(4)) + Convert.ToInt32(BRD.GetValue(4)), 4);
                valueSTATS.SetValue(Convert.ToInt32(valueSTATS.GetValue(5)) + Convert.ToInt32(BRD.GetValue(5)), 5);
                valueSTATS.SetValue(Convert.ToInt32(valueSTATS.GetValue(6)) + Convert.ToInt32(BRD.GetValue(6)), 6);
            }
            if (arrayClasses.Contains("BST") || arrayClasses.Contains(" BST"))
            {
                valueSTATS.SetValue(Convert.ToInt32(valueSTATS.GetValue(0)) + Convert.ToInt32(BST.GetValue(0)), 0);
                valueSTATS.SetValue(Convert.ToInt32(valueSTATS.GetValue(1)) + Convert.ToInt32(BST.GetValue(1)), 1);
                valueSTATS.SetValue(Convert.ToInt32(valueSTATS.GetValue(2)) + Convert.ToInt32(BST.GetValue(2)), 2);
                valueSTATS.SetValue(Convert.ToInt32(valueSTATS.GetValue(3)) + Convert.ToInt32(BST.GetValue(3)), 3);
                valueSTATS.SetValue(Convert.ToInt32(valueSTATS.GetValue(4)) + Convert.ToInt32(BST.GetValue(4)), 4);
                valueSTATS.SetValue(Convert.ToInt32(valueSTATS.GetValue(5)) + Convert.ToInt32(BST.GetValue(5)), 5);
                valueSTATS.SetValue(Convert.ToInt32(valueSTATS.GetValue(6)) + Convert.ToInt32(BST.GetValue(6)), 6);
            }
            if (arrayClasses.Contains("CLE") || arrayClasses.Contains(" CLE"))
            {
                valueSTATS.SetValue(Convert.ToInt32(valueSTATS.GetValue(0)) + Convert.ToInt32(CLE.GetValue(0)), 0);
                valueSTATS.SetValue(Convert.ToInt32(valueSTATS.GetValue(1)) + Convert.ToInt32(CLE.GetValue(1)), 1);
                valueSTATS.SetValue(Convert.ToInt32(valueSTATS.GetValue(2)) + Convert.ToInt32(CLE.GetValue(2)), 2);
                valueSTATS.SetValue(Convert.ToInt32(valueSTATS.GetValue(3)) + Convert.ToInt32(CLE.GetValue(3)), 3);
                valueSTATS.SetValue(Convert.ToInt32(valueSTATS.GetValue(4)) + Convert.ToInt32(CLE.GetValue(4)), 4);
                valueSTATS.SetValue(Convert.ToInt32(valueSTATS.GetValue(5)) + Convert.ToInt32(CLE.GetValue(5)), 5);
                valueSTATS.SetValue(Convert.ToInt32(valueSTATS.GetValue(6)) + Convert.ToInt32(CLE.GetValue(6)), 6);
            }
            if (arrayClasses.Contains("DRU") || arrayClasses.Contains(" DRU"))
            {
                valueSTATS.SetValue(Convert.ToInt32(valueSTATS.GetValue(0)) + Convert.ToInt32(DRU.GetValue(0)), 0);
                valueSTATS.SetValue(Convert.ToInt32(valueSTATS.GetValue(1)) + Convert.ToInt32(DRU.GetValue(1)), 1);
                valueSTATS.SetValue(Convert.ToInt32(valueSTATS.GetValue(2)) + Convert.ToInt32(DRU.GetValue(2)), 2);
                valueSTATS.SetValue(Convert.ToInt32(valueSTATS.GetValue(3)) + Convert.ToInt32(DRU.GetValue(3)), 3);
                valueSTATS.SetValue(Convert.ToInt32(valueSTATS.GetValue(4)) + Convert.ToInt32(DRU.GetValue(4)), 4);
                valueSTATS.SetValue(Convert.ToInt32(valueSTATS.GetValue(5)) + Convert.ToInt32(DRU.GetValue(5)), 5);
                valueSTATS.SetValue(Convert.ToInt32(valueSTATS.GetValue(6)) + Convert.ToInt32(DRU.GetValue(6)), 6);
            }
            if (arrayClasses.Contains("ENC") || arrayClasses.Contains(" ENC"))
            {
                valueSTATS.SetValue(Convert.ToInt32(valueSTATS.GetValue(0)) + Convert.ToInt32(ENC.GetValue(0)), 0);
                valueSTATS.SetValue(Convert.ToInt32(valueSTATS.GetValue(1)) + Convert.ToInt32(ENC.GetValue(1)), 1);
                valueSTATS.SetValue(Convert.ToInt32(valueSTATS.GetValue(2)) + Convert.ToInt32(ENC.GetValue(2)), 2);
                valueSTATS.SetValue(Convert.ToInt32(valueSTATS.GetValue(3)) + Convert.ToInt32(ENC.GetValue(3)), 3);
                valueSTATS.SetValue(Convert.ToInt32(valueSTATS.GetValue(4)) + Convert.ToInt32(ENC.GetValue(4)), 4);
                valueSTATS.SetValue(Convert.ToInt32(valueSTATS.GetValue(5)) + Convert.ToInt32(ENC.GetValue(5)), 5);
                valueSTATS.SetValue(Convert.ToInt32(valueSTATS.GetValue(6)) + Convert.ToInt32(ENC.GetValue(6)), 6);
            }
            if (arrayClasses.Contains("MAG") || arrayClasses.Contains(" MAG"))
            {
                valueSTATS.SetValue(Convert.ToInt32(valueSTATS.GetValue(0)) + Convert.ToInt32(MAG.GetValue(0)), 0);
                valueSTATS.SetValue(Convert.ToInt32(valueSTATS.GetValue(1)) + Convert.ToInt32(MAG.GetValue(1)), 1);
                valueSTATS.SetValue(Convert.ToInt32(valueSTATS.GetValue(2)) + Convert.ToInt32(MAG.GetValue(2)), 2);
                valueSTATS.SetValue(Convert.ToInt32(valueSTATS.GetValue(3)) + Convert.ToInt32(MAG.GetValue(3)), 3);
                valueSTATS.SetValue(Convert.ToInt32(valueSTATS.GetValue(4)) + Convert.ToInt32(MAG.GetValue(4)), 4);
                valueSTATS.SetValue(Convert.ToInt32(valueSTATS.GetValue(5)) + Convert.ToInt32(MAG.GetValue(5)), 5);
                valueSTATS.SetValue(Convert.ToInt32(valueSTATS.GetValue(6)) + Convert.ToInt32(MAG.GetValue(6)), 6);
            }
            if (arrayClasses.Contains("MNK") || arrayClasses.Contains(" MNK"))
            {
                valueSTATS.SetValue(Convert.ToInt32(valueSTATS.GetValue(0)) + Convert.ToInt32(MNK.GetValue(0)), 0);
                valueSTATS.SetValue(Convert.ToInt32(valueSTATS.GetValue(1)) + Convert.ToInt32(MNK.GetValue(1)), 1);
                valueSTATS.SetValue(Convert.ToInt32(valueSTATS.GetValue(2)) + Convert.ToInt32(MNK.GetValue(2)), 2);
                valueSTATS.SetValue(Convert.ToInt32(valueSTATS.GetValue(3)) + Convert.ToInt32(MNK.GetValue(3)), 3);
                valueSTATS.SetValue(Convert.ToInt32(valueSTATS.GetValue(4)) + Convert.ToInt32(MNK.GetValue(4)), 4);
                valueSTATS.SetValue(Convert.ToInt32(valueSTATS.GetValue(5)) + Convert.ToInt32(MNK.GetValue(5)), 5);
                valueSTATS.SetValue(Convert.ToInt32(valueSTATS.GetValue(6)) + Convert.ToInt32(MNK.GetValue(6)), 6);
            }
            if (arrayClasses.Contains("NEC") || arrayClasses.Contains(" NEC"))
            {
                valueSTATS.SetValue(Convert.ToInt32(valueSTATS.GetValue(0)) + Convert.ToInt32(NEC.GetValue(0)), 0);
                valueSTATS.SetValue(Convert.ToInt32(valueSTATS.GetValue(1)) + Convert.ToInt32(NEC.GetValue(1)), 1);
                valueSTATS.SetValue(Convert.ToInt32(valueSTATS.GetValue(2)) + Convert.ToInt32(NEC.GetValue(2)), 2);
                valueSTATS.SetValue(Convert.ToInt32(valueSTATS.GetValue(3)) + Convert.ToInt32(NEC.GetValue(3)), 3);
                valueSTATS.SetValue(Convert.ToInt32(valueSTATS.GetValue(4)) + Convert.ToInt32(NEC.GetValue(4)), 4);
                valueSTATS.SetValue(Convert.ToInt32(valueSTATS.GetValue(5)) + Convert.ToInt32(NEC.GetValue(5)), 5);
                valueSTATS.SetValue(Convert.ToInt32(valueSTATS.GetValue(6)) + Convert.ToInt32(NEC.GetValue(6)), 6);
            }
            if (arrayClasses.Contains("PAL") || arrayClasses.Contains(" PAL"))
            {
                valueSTATS.SetValue(Convert.ToInt32(valueSTATS.GetValue(0)) + Convert.ToInt32(PAL.GetValue(0)), 0);
                valueSTATS.SetValue(Convert.ToInt32(valueSTATS.GetValue(1)) + Convert.ToInt32(PAL.GetValue(1)), 1);
                valueSTATS.SetValue(Convert.ToInt32(valueSTATS.GetValue(2)) + Convert.ToInt32(PAL.GetValue(2)), 2);
                valueSTATS.SetValue(Convert.ToInt32(valueSTATS.GetValue(3)) + Convert.ToInt32(PAL.GetValue(3)), 3);
                valueSTATS.SetValue(Convert.ToInt32(valueSTATS.GetValue(4)) + Convert.ToInt32(PAL.GetValue(4)), 4);
                valueSTATS.SetValue(Convert.ToInt32(valueSTATS.GetValue(5)) + Convert.ToInt32(PAL.GetValue(5)), 5);
                valueSTATS.SetValue(Convert.ToInt32(valueSTATS.GetValue(6)) + Convert.ToInt32(PAL.GetValue(6)), 6);
            }
            if (arrayClasses.Contains("RNG") || arrayClasses.Contains(" RNG"))
            {
                valueSTATS.SetValue(Convert.ToInt32(valueSTATS.GetValue(0)) + Convert.ToInt32(RNG.GetValue(0)), 0);
                valueSTATS.SetValue(Convert.ToInt32(valueSTATS.GetValue(1)) + Convert.ToInt32(RNG.GetValue(1)), 1);
                valueSTATS.SetValue(Convert.ToInt32(valueSTATS.GetValue(2)) + Convert.ToInt32(RNG.GetValue(2)), 2);
                valueSTATS.SetValue(Convert.ToInt32(valueSTATS.GetValue(3)) + Convert.ToInt32(RNG.GetValue(3)), 3);
                valueSTATS.SetValue(Convert.ToInt32(valueSTATS.GetValue(4)) + Convert.ToInt32(RNG.GetValue(4)), 4);
                valueSTATS.SetValue(Convert.ToInt32(valueSTATS.GetValue(5)) + Convert.ToInt32(RNG.GetValue(5)), 5);
                valueSTATS.SetValue(Convert.ToInt32(valueSTATS.GetValue(6)) + Convert.ToInt32(RNG.GetValue(6)), 6);
            }
            if (arrayClasses.Contains("ROG") || arrayClasses.Contains(" ROG"))
            {
                valueSTATS.SetValue(Convert.ToInt32(valueSTATS.GetValue(0)) + Convert.ToInt32(ROG.GetValue(0)), 0);
                valueSTATS.SetValue(Convert.ToInt32(valueSTATS.GetValue(1)) + Convert.ToInt32(ROG.GetValue(1)), 1);
                valueSTATS.SetValue(Convert.ToInt32(valueSTATS.GetValue(2)) + Convert.ToInt32(ROG.GetValue(2)), 2);
                valueSTATS.SetValue(Convert.ToInt32(valueSTATS.GetValue(3)) + Convert.ToInt32(ROG.GetValue(3)), 3);
                valueSTATS.SetValue(Convert.ToInt32(valueSTATS.GetValue(4)) + Convert.ToInt32(ROG.GetValue(4)), 4);
                valueSTATS.SetValue(Convert.ToInt32(valueSTATS.GetValue(5)) + Convert.ToInt32(ROG.GetValue(5)), 5);
                valueSTATS.SetValue(Convert.ToInt32(valueSTATS.GetValue(6)) + Convert.ToInt32(ROG.GetValue(6)), 6);
            }
            if (arrayClasses.Contains("SHD") || arrayClasses.Contains(" SHD"))
            {
                valueSTATS.SetValue(Convert.ToInt32(valueSTATS.GetValue(0)) + Convert.ToInt32(SHD.GetValue(0)), 0);
                valueSTATS.SetValue(Convert.ToInt32(valueSTATS.GetValue(1)) + Convert.ToInt32(SHD.GetValue(1)), 1);
                valueSTATS.SetValue(Convert.ToInt32(valueSTATS.GetValue(2)) + Convert.ToInt32(SHD.GetValue(2)), 2);
                valueSTATS.SetValue(Convert.ToInt32(valueSTATS.GetValue(3)) + Convert.ToInt32(SHD.GetValue(3)), 3);
                valueSTATS.SetValue(Convert.ToInt32(valueSTATS.GetValue(4)) + Convert.ToInt32(SHD.GetValue(4)), 4);
                valueSTATS.SetValue(Convert.ToInt32(valueSTATS.GetValue(5)) + Convert.ToInt32(SHD.GetValue(5)), 5);
                valueSTATS.SetValue(Convert.ToInt32(valueSTATS.GetValue(6)) + Convert.ToInt32(SHD.GetValue(6)), 6);
            }
            if (arrayClasses.Contains("SHM") || arrayClasses.Contains(" SHM"))
            {
                valueSTATS.SetValue(Convert.ToInt32(valueSTATS.GetValue(0)) + Convert.ToInt32(SHM.GetValue(0)), 0);
                valueSTATS.SetValue(Convert.ToInt32(valueSTATS.GetValue(1)) + Convert.ToInt32(SHM.GetValue(1)), 1);
                valueSTATS.SetValue(Convert.ToInt32(valueSTATS.GetValue(2)) + Convert.ToInt32(SHM.GetValue(2)), 2);
                valueSTATS.SetValue(Convert.ToInt32(valueSTATS.GetValue(3)) + Convert.ToInt32(SHM.GetValue(3)), 3);
                valueSTATS.SetValue(Convert.ToInt32(valueSTATS.GetValue(4)) + Convert.ToInt32(SHM.GetValue(4)), 4);
                valueSTATS.SetValue(Convert.ToInt32(valueSTATS.GetValue(5)) + Convert.ToInt32(SHM.GetValue(5)), 5);
                valueSTATS.SetValue(Convert.ToInt32(valueSTATS.GetValue(6)) + Convert.ToInt32(SHM.GetValue(6)), 6);
            }
            if (arrayClasses.Contains("WAR") || arrayClasses.Contains(" WAR"))
            {
                valueSTATS.SetValue(Convert.ToInt32(valueSTATS.GetValue(0)) + Convert.ToInt32(WAR.GetValue(0)), 0);
                valueSTATS.SetValue(Convert.ToInt32(valueSTATS.GetValue(1)) + Convert.ToInt32(WAR.GetValue(1)), 1);
                valueSTATS.SetValue(Convert.ToInt32(valueSTATS.GetValue(2)) + Convert.ToInt32(WAR.GetValue(2)), 2);
                valueSTATS.SetValue(Convert.ToInt32(valueSTATS.GetValue(3)) + Convert.ToInt32(WAR.GetValue(3)), 3);
                valueSTATS.SetValue(Convert.ToInt32(valueSTATS.GetValue(4)) + Convert.ToInt32(WAR.GetValue(4)), 4);
                valueSTATS.SetValue(Convert.ToInt32(valueSTATS.GetValue(5)) + Convert.ToInt32(WAR.GetValue(5)), 5);
                valueSTATS.SetValue(Convert.ToInt32(valueSTATS.GetValue(6)) + Convert.ToInt32(WAR.GetValue(6)), 6);
            }
            if (arrayClasses.Contains("WIZ") || arrayClasses.Contains(" WIZ"))
            {
                valueSTATS.SetValue(Convert.ToInt32(valueSTATS.GetValue(0)) + Convert.ToInt32(WIZ.GetValue(0)), 0);
                valueSTATS.SetValue(Convert.ToInt32(valueSTATS.GetValue(1)) + Convert.ToInt32(WIZ.GetValue(1)), 1);
                valueSTATS.SetValue(Convert.ToInt32(valueSTATS.GetValue(2)) + Convert.ToInt32(WIZ.GetValue(2)), 2);
                valueSTATS.SetValue(Convert.ToInt32(valueSTATS.GetValue(3)) + Convert.ToInt32(WIZ.GetValue(3)), 3);
                valueSTATS.SetValue(Convert.ToInt32(valueSTATS.GetValue(4)) + Convert.ToInt32(WIZ.GetValue(4)), 4);
                valueSTATS.SetValue(Convert.ToInt32(valueSTATS.GetValue(5)) + Convert.ToInt32(WIZ.GetValue(5)), 5);
                valueSTATS.SetValue(Convert.ToInt32(valueSTATS.GetValue(6)) + Convert.ToInt32(WIZ.GetValue(6)), 6);
            }

            totalSTATS = Convert.ToInt32(valueSTATS.GetValue(0)) + Convert.ToInt32(valueSTATS.GetValue(1)) + Convert.ToInt32(valueSTATS.GetValue(2)) + Convert.ToInt32(valueSTATS.GetValue(3)) + Convert.ToInt32(valueSTATS.GetValue(4)) + Convert.ToInt32(valueSTATS.GetValue(5)) + Convert.ToInt32(valueSTATS.GetValue(6));
            //Console.WriteLine(valueSTATS.GetValue(0) + " " + valueSTATS.GetValue(1) + " " + valueSTATS.GetValue(2) + " " + valueSTATS.GetValue(3) + " " + valueSTATS.GetValue(4) + " " + valueSTATS.GetValue(5) + " " + valueSTATS.GetValue(6));

            if (boolBoss)
            {
                int toCalculate = (((baseStats * intTierToTier / 10000) * (intTier - 1)) + baseStats);
                //Console.WriteLine("Total Stats: " + toCalculate);
                txtSTR.Text = Convert.ToString(toCalculate * Convert.ToInt32(valueSTATS.GetValue(0)) / totalSTATS);
                txtSTA.Text = Convert.ToString(toCalculate * Convert.ToInt32(valueSTATS.GetValue(1)) / totalSTATS);
                txtAGI.Text = Convert.ToString(toCalculate * Convert.ToInt32(valueSTATS.GetValue(2)) / totalSTATS);
                txtDEX.Text = Convert.ToString(toCalculate * Convert.ToInt32(valueSTATS.GetValue(3)) / totalSTATS);
                txtWIS.Text = Convert.ToString(toCalculate * Convert.ToInt32(valueSTATS.GetValue(4)) / totalSTATS);
                txtINT.Text = Convert.ToString(toCalculate * Convert.ToInt32(valueSTATS.GetValue(5)) / totalSTATS);
                txtCHA.Text = Convert.ToString(toCalculate * Convert.ToInt32(valueSTATS.GetValue(6)) / totalSTATS);
            }
            else if (boolDonor)
            {
                int toCalculate = (((baseStats * intDonorToTier / 10000) * (intTier - 1)) + baseStats);
                //Console.WriteLine("Total Stats: " + toCalculate);
                txtSTR.Text = Convert.ToString(toCalculate * Convert.ToInt32(valueSTATS.GetValue(0)) / totalSTATS);
                txtSTA.Text = Convert.ToString(toCalculate * Convert.ToInt32(valueSTATS.GetValue(1)) / totalSTATS);
                txtAGI.Text = Convert.ToString(toCalculate * Convert.ToInt32(valueSTATS.GetValue(2)) / totalSTATS);
                txtDEX.Text = Convert.ToString(toCalculate * Convert.ToInt32(valueSTATS.GetValue(3)) / totalSTATS);
                txtWIS.Text = Convert.ToString(toCalculate * Convert.ToInt32(valueSTATS.GetValue(4)) / totalSTATS);
                txtINT.Text = Convert.ToString(toCalculate * Convert.ToInt32(valueSTATS.GetValue(5)) / totalSTATS);
                txtCHA.Text = Convert.ToString(toCalculate * Convert.ToInt32(valueSTATS.GetValue(6)) / totalSTATS);
            }
            else
            {
                int toCalculate = (((baseStats * intTierToTier / 10000) * (intTier - 1)) + baseStats * intDungeon / 100);
                //Console.WriteLine("Total Stats: " + toCalculate);
                txtSTR.Text = Convert.ToString(toCalculate * Convert.ToInt32(valueSTATS.GetValue(0)) / totalSTATS);
                txtSTA.Text = Convert.ToString(toCalculate * Convert.ToInt32(valueSTATS.GetValue(1)) / totalSTATS);
                txtAGI.Text = Convert.ToString(toCalculate * Convert.ToInt32(valueSTATS.GetValue(2)) / totalSTATS);
                txtDEX.Text = Convert.ToString(toCalculate * Convert.ToInt32(valueSTATS.GetValue(3)) / totalSTATS);
                txtWIS.Text = Convert.ToString(toCalculate * Convert.ToInt32(valueSTATS.GetValue(4)) / totalSTATS);
                txtINT.Text = Convert.ToString(toCalculate * Convert.ToInt32(valueSTATS.GetValue(5)) / totalSTATS);
                txtCHA.Text = Convert.ToString(toCalculate * Convert.ToInt32(valueSTATS.GetValue(6)) / totalSTATS);
            }
        }

        private void CalcHSTATS(int intTier, bool boolBoss, bool boolDonor, string strTopSlot)
        {

            int baseStats = 0;                      // Base number of stats on a Tier 1 item.
            int baseDonor = 35;                     // Base number of stats on a donor item.
            int baseDonorChest = 105;               // Base number of stats on donor chest.
            int baseDonorLegs = 84;                 // Base number of stats on donor legs.
            int intMultiplier;
            string strStatList;

            txtHSTR.Text = "0";
            txtHSTA.Text = "0";
            txtHAGI.Text = "0";
            txtHDEX.Text = "0";
            txtHWIS.Text = "0";
            txtHINT.Text = "0";
            txtHCHA.Text = "0";

            if (intTier >= 8 && boolBoss)
            {
                if (Math.Abs(intTier - 8) == 0)
                {
                    baseStats = 5;
                }
                else if (Math.Abs(intTier - 8) >= 1)
                {
                    intMultiplier = Math.Abs((intTier - 8)+1);
                    baseStats = 5 * intMultiplier;
                }

                strStatList = txtSTR.Text + "," + txtSTA.Text + "," + txtAGI.Text + "," + txtDEX.Text + "," + txtWIS.Text + "," + txtINT.Text + "," + txtCHA.Text;

                List<string> arrayStats = strStatList.Split(',').ToList(); // Convert list of classes into array
                arrayStats.Sort();
                arrayStats.Reverse();

                for (int i = 0; i < 3; i++)
                {
                    if (Convert.ToInt32(txtSTR.Text) == Convert.ToInt32(arrayStats[i]) && txtHSTR.Text == "0")
                    {
                        if (i == 0) { txtHSTR.Text = Convert.ToString(Math.Abs(baseStats * .4)); }
                        if (i == 1) { txtHSTR.Text = Convert.ToString(Math.Abs(baseStats * .4)); }
                        if (i == 2) { txtHSTR.Text = Convert.ToString(Math.Abs(baseStats * .2)); }
                    }
                    else if (Convert.ToInt32(txtSTA.Text) == Convert.ToInt32(arrayStats[i]) && txtHSTA.Text == "0")
                    {
                        if (i == 0) { txtHSTA.Text = Convert.ToString(Math.Abs(baseStats * .4)); }
                        if (i == 1) { txtHSTA.Text = Convert.ToString(Math.Abs(baseStats * .4)); }
                        if (i == 2) { txtHSTA.Text = Convert.ToString(Math.Abs(baseStats * .2)); }
                    }
                    else if (Convert.ToInt32(txtAGI.Text) == Convert.ToInt32(arrayStats[i]) && txtHAGI.Text == "0")
                    {
                        if (i == 0) { txtHAGI.Text = Convert.ToString(Math.Abs(baseStats * .4)); }
                        if (i == 1) { txtHAGI.Text = Convert.ToString(Math.Abs(baseStats * .4)); }
                        if (i == 2) { txtHAGI.Text = Convert.ToString(Math.Abs(baseStats * .2)); }
                    }
                    else if (Convert.ToInt32(txtDEX.Text) == Convert.ToInt32(arrayStats[i]) && txtHDEX.Text == "0")
                    {
                        if (i == 0) { txtHDEX.Text = Convert.ToString(Math.Abs(baseStats * .4)); }
                        if (i == 1) { txtHDEX.Text = Convert.ToString(Math.Abs(baseStats * .4)); }
                        if (i == 2) { txtHDEX.Text = Convert.ToString(Math.Abs(baseStats * .2)); }
                    }
                    else if (Convert.ToInt32(txtWIS.Text) == Convert.ToInt32(arrayStats[i]) && txtHWIS.Text == "0")
                    {
                        if (i == 0) { txtHWIS.Text = Convert.ToString(Math.Abs(baseStats * .4)); }
                        if (i == 1) { txtHWIS.Text = Convert.ToString(Math.Abs(baseStats * .4)); }
                        if (i == 2) { txtHWIS.Text = Convert.ToString(Math.Abs(baseStats * .2)); }
                    }
                    else if (Convert.ToInt32(txtINT.Text) == Convert.ToInt32(arrayStats[i]) && txtHINT.Text == "0")
                    {
                        if (i == 0) { txtHINT.Text = Convert.ToString(Math.Abs(baseStats * .4)); }
                        if (i == 1) { txtHINT.Text = Convert.ToString(Math.Abs(baseStats * .4)); }
                        if (i == 2) { txtHINT.Text = Convert.ToString(Math.Abs(baseStats * .2)); }
                    }
                    else if (Convert.ToInt32(txtCHA.Text) == Convert.ToInt32(arrayStats[i]) && txtHCHA.Text == "0")
                    {
                        if (i == 0) { txtHCHA.Text = Convert.ToString(Math.Abs(baseStats * .4)); }
                        if (i == 1) { txtHCHA.Text = Convert.ToString(Math.Abs(baseStats * .4)); }
                        if (i == 2) { txtHCHA.Text = Convert.ToString(Math.Abs(baseStats * .2)); }
                    }
                } 
            
            }
            else if (boolDonor)
            {
                if (strTopSlot == "Chest")
                {
                    txtHSTR.Text = Convert.ToString(Math.Round(Math.Abs(baseDonorChest * .14), 0));
                    txtHSTA.Text = Convert.ToString(Math.Round(Math.Abs(baseDonorChest * .14), 0));
                    txtHAGI.Text = Convert.ToString(Math.Round(Math.Abs(baseDonorChest * .14), 0));
                    txtHDEX.Text = Convert.ToString(Math.Round(Math.Abs(baseDonorChest * .14), 0));
                    txtHWIS.Text = Convert.ToString(Math.Round(Math.Abs(baseDonorChest * .14), 0));
                    txtHINT.Text = Convert.ToString(Math.Round(Math.Abs(baseDonorChest * .14), 0));
                    txtHCHA.Text = Convert.ToString(Math.Round(Math.Abs(baseDonorChest * .14), 0));
                }
                else if (strTopSlot == "Legs")
                {
                    txtHSTR.Text = Convert.ToString(Math.Round(Math.Abs(baseDonorLegs * .14), 0));
                    txtHSTA.Text = Convert.ToString(Math.Round(Math.Abs(baseDonorLegs * .14), 0));
                    txtHAGI.Text = Convert.ToString(Math.Round(Math.Abs(baseDonorLegs * .14), 0));
                    txtHDEX.Text = Convert.ToString(Math.Round(Math.Abs(baseDonorLegs * .14), 0));
                    txtHWIS.Text = Convert.ToString(Math.Round(Math.Abs(baseDonorLegs * .14), 0));
                    txtHINT.Text = Convert.ToString(Math.Round(Math.Abs(baseDonorLegs * .14), 0));
                    txtHCHA.Text = Convert.ToString(Math.Round(Math.Abs(baseDonorLegs * .14), 0));
                }
                else
                {
                    txtHSTR.Text = Convert.ToString(Math.Round(Math.Abs(baseDonor * .14), 0));
                    txtHSTA.Text = Convert.ToString(Math.Round(Math.Abs(baseDonor * .14), 0));
                    txtHAGI.Text = Convert.ToString(Math.Round(Math.Abs(baseDonor * .14), 0));
                    txtHDEX.Text = Convert.ToString(Math.Round(Math.Abs(baseDonor * .14), 0));
                    txtHWIS.Text = Convert.ToString(Math.Round(Math.Abs(baseDonor * .14), 0));
                    txtHINT.Text = Convert.ToString(Math.Round(Math.Abs(baseDonor * .14), 0));
                    txtHCHA.Text = Convert.ToString(Math.Round(Math.Abs(baseDonor * .14), 0));
                }
            }
        }

        private void CalcAC(int intTier, string strMaterial, bool boolBoss, bool boolDonor, string strTopSlot)
        {
            int baseChest = 50;                         // Base value for Chest Piece
            int baseLegs = 35;                          // Base value for Legs
            int baseVisible = 30;                       // Base value for remaining visible pieces (Helm, Arms, Wrists, Boots)
            int baseOther = 25;                         // Base value for all other pieces.

            double armorValue = 0;

            bool tierOne = true;
            int toCalculate = 0;

            double dungeonMod = 0.9;                    // % difference between End Boss and Dungeon loot (HUNDREDS - EX. 90 / 100)
            double intTierToTier = .175;                // % difference between Tier and Tier gear. (THOUSANDS - EX. 1750 / 10000)
            double intDonorToTier = .25;                // % difference between Donor and Tier gear. (THOUSANDS - EX. 2500 / 10000)

            if (strMaterial == "Silk")          { armorValue = 1.2; }
            if (strMaterial == "Leather")       { armorValue = 1.3; }
            if (strMaterial == "Chain")         { armorValue = 1.7; }
            if (strMaterial == "Plate")         { armorValue = 2.1; }
            if (strMaterial == "Shield")        { armorValue = 2.7; }
            if (strMaterial == "Accessory")     { armorValue = 1.05; }
            if (strMaterial == "Archery")       { armorValue = 1.3; }
            if (strMaterial == "1h Blunt")      { armorValue = 1.15; }
            if (strMaterial == "1h Piercing")   { armorValue = 1.15; }
            if (strMaterial == "1h Slashing")   { armorValue = 1.15; }
            if (strMaterial == "2h Blunt")      { armorValue = 1.3; }
            if (strMaterial == "2h Piercing")   { armorValue = 1.3; }
            if (strMaterial == "2h Slashing")   { armorValue = 1.3; }
            if (strMaterial == "Martial")       { armorValue = 1.15; }


            if (intTier == 1)
            {
                tierOne = true;
            }
            else if (intTier > 1)
            {
                tierOne = false;
            }

            if (strTopSlot == "Chest")
            {
                if (boolBoss)
                {
                    if (tierOne) { toCalculate = Convert.ToInt32(baseChest * armorValue); }
                    if (!tierOne) { toCalculate = Convert.ToInt32((((baseChest * intTierToTier) * intTier) + baseChest) * armorValue); }
                    txtAC.Text = Convert.ToString(toCalculate);
                }
                else
                {
                    if (tierOne) { toCalculate = Convert.ToInt32((baseChest * armorValue) * dungeonMod); }
                    if (!tierOne) { toCalculate = Convert.ToInt32(((((baseChest * intTierToTier) * intTier) + baseChest) * armorValue) * dungeonMod); }
                    txtAC.Text = Convert.ToString(toCalculate);
                }

                if (boolDonor)
                {
                    if (tierOne) { toCalculate = Convert.ToInt32(baseChest * armorValue); }
                    if (!tierOne) { toCalculate = Convert.ToInt32((((baseChest * intDonorToTier) * intTier) + baseChest) * armorValue); }
                    txtAC.Text = Convert.ToString(toCalculate);
                }
            }
            else if (strTopSlot == "Legs")
            {
                if (boolBoss)
                {
                    if (tierOne) { toCalculate = Convert.ToInt32(baseLegs * armorValue); }
                    if (!tierOne) { toCalculate = Convert.ToInt32((((baseLegs * intTierToTier) * intTier) + baseLegs) * armorValue); }
                    txtAC.Text = Convert.ToString(toCalculate);
                }
                else
                {
                    if (tierOne) { toCalculate = Convert.ToInt32((baseLegs * armorValue) * dungeonMod); }
                    if (!tierOne) { toCalculate = Convert.ToInt32(((((baseLegs * intTierToTier) * intTier) + baseLegs) * armorValue) * dungeonMod); }
                    txtAC.Text = Convert.ToString(toCalculate);
                }

                if (boolDonor)
                {
                    if (tierOne) { toCalculate = Convert.ToInt32(baseLegs * armorValue); }
                    if (!tierOne) { toCalculate = Convert.ToInt32((((baseLegs * intDonorToTier) * intTier) + baseLegs) * armorValue); }
                    txtAC.Text = Convert.ToString(toCalculate);
                }
            }
            else if (strTopSlot == "Head" || strTopSlot == "Arms" || strTopSlot == "Wrist" || strTopSlot == "Feet" || strTopSlot == "Hands")
            {
                if (boolBoss)
                {
                    if (tierOne) { toCalculate = Convert.ToInt32(baseVisible * armorValue); }
                    if (!tierOne) { toCalculate = Convert.ToInt32((((baseVisible * intTierToTier) * intTier) + baseVisible) * armorValue); }
                    txtAC.Text = Convert.ToString(toCalculate);
                }
                else
                {
                    if (tierOne) { toCalculate = Convert.ToInt32((baseVisible * armorValue) * dungeonMod); }
                    if (!tierOne) { toCalculate = Convert.ToInt32(((((baseVisible * intTierToTier) * intTier) + baseVisible) * armorValue) * dungeonMod); }
                    txtAC.Text = Convert.ToString(toCalculate);
                }

                if (boolDonor)
                {
                    if (tierOne) { toCalculate = Convert.ToInt32(baseVisible * armorValue); }
                    if (!tierOne) { toCalculate = Convert.ToInt32((((baseVisible * intDonorToTier) * intTier) + baseVisible) * armorValue); }
                    txtAC.Text = Convert.ToString(toCalculate);
                }
            }
            else
            {
                if (boolBoss)
                {
                    if (tierOne) { toCalculate = Convert.ToInt32(baseOther * armorValue); }
                    if (!tierOne) { toCalculate = Convert.ToInt32((((baseOther * intTierToTier) * intTier) + baseOther) * armorValue); }
                    txtAC.Text = Convert.ToString(toCalculate);
                }
                else
                {
                    if (tierOne) { toCalculate = Convert.ToInt32((baseOther * armorValue) * dungeonMod); }
                    if (!tierOne) { toCalculate = Convert.ToInt32(((((baseOther * intTierToTier) * intTier) + baseOther) * armorValue) * dungeonMod); }
                    txtAC.Text = Convert.ToString(toCalculate);
                }

                if (boolDonor)
                {
                    if (tierOne) { toCalculate = Convert.ToInt32(baseOther * armorValue); }
                    if (!tierOne) { toCalculate = Convert.ToInt32((((baseOther * intDonorToTier) * intTier) + baseOther) * armorValue); }
                    txtAC.Text = Convert.ToString(toCalculate);
                }
            }
        }

        private void CalcDAMAGE(int intTier, string strMaterial, bool boolBoss, bool boolDonor, string strTopSlot)
        {

            bool tierOne = true;
            int toCalculate = 0;
            double damageValue = 0;
            int delayValue = 0;
            int baseDAM = 0;
            int baseDEL = 0;
            int damRatio = 0;

            double dungeonMod = 0.9;                    // % difference between End Boss and Dungeon loot (HUNDREDS - EX. 90 / 100)
            double intTierToTier = .155;                // % difference between Tier and Tier gear. (THOUSANDS - EX. 1750 / 10000)
            double intDonorToTier = .25;                // % difference between Donor and Tier gear. (THOUSANDS - EX. 2500 / 10000)

            if (strMaterial == "Archery")       { damageValue = 1; delayValue = 1; baseDAM = 90; baseDEL = 25; }
            if (strMaterial == "1h Blunt")      { damageValue = 1; delayValue = 1; baseDAM = 40; baseDEL = 24; }
            if (strMaterial == "1h Piercing")   { damageValue = 1; delayValue = 1; baseDAM = 30; baseDEL = 20; }
            if (strMaterial == "1h Slashing")   { damageValue = 1; delayValue = 1; baseDAM = 35; baseDEL = 22; } 
            if (strMaterial == "2h Blunt")      { damageValue = 1; delayValue = 1; baseDAM = 90; baseDEL = 40; }
            if (strMaterial == "2h Piercing")   { damageValue = 1; delayValue = 1; baseDAM = 70; baseDEL = 30; }
            if (strMaterial == "2h Slashing")   { damageValue = 1; delayValue = 1; baseDAM = 80; baseDEL = 35; }
            if (strMaterial == "Martial")       { damageValue = 1.15; delayValue = 1; baseDAM = 27; baseDEL = 18; }

            if (intTier == 1)
            {
                tierOne = true;
            }
            else if (intTier > 1)
            {
                tierOne = false;
            }

            if (strMaterial == "Archery" || strMaterial == "1h Blunt" || strMaterial == "2h Blunt" || strMaterial == "1h Piercing" || strMaterial == "2h Piercing" || strMaterial == "1h Slashing" || strMaterial == "2h Slashing" || strMaterial == "Martial")
            {
                if (boolBoss)
                {
                    if (tierOne) { toCalculate = Convert.ToInt32(baseDAM * damageValue); }
                    if (!tierOne) { toCalculate = Convert.ToInt32((((baseDAM * intTierToTier) * intTier) + baseDAM) * damageValue); }
                    txtDAMAGE.Text = Convert.ToString(toCalculate);
                    txtDELAY.Text = Convert.ToString(baseDEL * delayValue);
                }
                else
                {
                    if (tierOne) { toCalculate = Convert.ToInt32((baseDAM * damageValue) * dungeonMod); }
                    if (!tierOne) { toCalculate = Convert.ToInt32(((((baseDAM * intTierToTier) * intTier) + baseDAM) * damageValue) * dungeonMod); }
                    txtDAMAGE.Text = Convert.ToString(toCalculate);
                    txtDELAY.Text = Convert.ToString(baseDEL * delayValue);
                }
                if (boolDonor)
                {
                    if (tierOne) { toCalculate = Convert.ToInt32(baseDAM * damageValue); }
                    if (!tierOne) { toCalculate = Convert.ToInt32((((baseDAM * intDonorToTier) * intTier) + baseDAM) * damageValue); }
                    txtDAMAGE.Text = Convert.ToString(toCalculate);
                    txtDELAY.Text = Convert.ToString(baseDEL * delayValue);

                }
                lblRATIO.Text = "RATIO: " + damRatio;
            }
        }
    
    }
}
